﻿using System;
using System.Linq;
using System.Threading;
using System.Windows;

using TraceView.UI.Entities;

namespace TraceView
{
    public partial class App
    {
        private readonly Timer _autoSaveSettingsTimer;

        public App()
        {
            //Load settings and set auto-save timer for settings
            Settings.Load();
            _autoSaveSettingsTimer = new Timer(state => Settings.Save(), null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1));
        }

        protected override void OnExit(ExitEventArgs e)
        {
            _autoSaveSettingsTimer.Dispose();
            Settings.Save();
            base.OnExit(e);
        }
    }
}